Question: Let $\omega$ be a nonreal root of $z^3 = 1.$  Let $a_1,$ $a_2,$ $\dots,$ $a_n$ be real numbers such that
\[\frac{1}{a_1 + \omega} + \frac{1}{a_2 + \omega} + \dots + \frac{1}{a_n + \omega} = 2 + 5i.\]Compute
\[\frac{2a_1 - 1}{a_1^2 - a_1 + 1} + \frac{2a_2 - 1}{a_2^2 - a_2 + 1} + \dots + \frac{2a_n - 1}{a_n^2 - a_n + 1}.\]
Explanation: We have that $\omega^3 = 1.$  Then $\omega^3 - 1 = 0,$ which factors as $(\omega - 1)(\omega^2 + \omega + 1) = 0.$  Since $\omega$ is nonreal, $\omega^2 + \omega + 1 = 0.$  By the quadratic formula,
\[\omega = -\frac{1}{2} \pm \frac{\sqrt{3}}{2} i.\]Taking the conjugate of the given equation, we get
\[\frac{1}{a_1 + \overline{\omega}} + \frac{1}{a_2 + \overline{\omega}} + \dots + \frac{1}{a_n + \overline{\omega}} = 2 - 5i.\]Note that if $a$ is a real number, then
\begin{align*}
\frac{1}{a + \omega} + \frac{1}{a + \overline{\omega}} &= \frac{a + \omega + a + \overline{\omega}}{(a + \omega)(a + \overline{\omega})} \\
&= \frac{2a + \omega + \overline{\omega}}{a^2 + (\omega + \overline{\omega}) a + \omega \overline{\omega}} \\
&= \frac{2a - 1}{a^2 - a + 1}.
\end{align*}Therefore,
\begin{align*}
\sum_{k = 1}^n \frac{2a_k - 1}{a_k^2 - a_k + 1} &= \sum_{k = 1}^n \left( \frac{1}{a_k + \omega} + \frac{1}{a_k + \overline{\omega}} \right) \\
&= 2 + 5i + 2 - 5i \\
&= \boxed{4}.
\end{align*}